// vim:set tabstop=4 shiftwidth=4 softtabstop=4 expandtab foldcolumn=1 foldmethod=marker:
/**
 * Project: lteerp
 * File Name:   src/filter/CheckPrivate.java
 *
 *  Check user's Private and record user's action to log
 *
 *  @package:   com.m5anet.filter
 *  @author:    Mike.G  (hylinux@gmail.com)
 *  @license:   http://www.gnu.org/copyleft/lesser.html  LGPL License 2.1 
 *  @copyright: http://www.5anet.com
 *
 */

package com.m5anet.filter;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpSession;

import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Connection;


import java.io.IOException;

import com.m5anet.main.DBUtil;
import com.m5anet.sql.GenerateSQL;


public final class CheckPrivate implements Filter {
    private FilterConfig config = null;
//    private GenerateSQL mysql = new GenerateSQL(getClass().getName() );

    /**
     * inital the config object;
     */
    public void init(FilterConfig config) {
        this.config = config;
    }

    /**
     * do the filter work
     */
    public void doFilter(
            ServletRequest req,
            ServletResponse res,
            FilterChain chain) throws ServletException,IOException {
        //
        //get the client session
        HttpSession session = ( (HttpServletRequest)req).getSession();

        //get the user name.
        //in here, we can think the user had logined, because 
        //we had setted one filter before this filter
        String userName = (String)session.getAttribute("username");

        //get the client request URI
        String requestURL = ( ( HttpServletRequest) req ).getServletPath();

        //check the user's group id, uid
        DBUtil dbUtil = DBUtil.getInstance();
        Connection dbh = dbUtil.getConnection();





    }

    public void destroy() {


    }
}
